using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using MacomberMap.Common.Internals;
using MacomberMap.Common.Types;
using System.Data.Common;

namespace MacomberMap.Common.Components
{
    /// <summary>
    /// This class handles a note on a particular object
    /// </summary>
    [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
    public class MM_Note : MM_Serializable
    {
        #region Variable declarations
        /// <summary>The unique identifier for this note</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
        public UInt64 ID;

        /// <summary>When the note was created</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
        public DateTime CreatedOn;

        /// <summary>Who authored the note</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
        public String Author;

        /// <summary>The text of the note</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
        public String Note;

        /// <summary>The element associated with the note.</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
        public MM_Element AssociatedElement;

        /// <summary>If the note has been acknowledged by the user</summary>
        public bool Acknowledged = false;
        #endregion

        #region Initialization
        /// <summary>
        /// Initialize a new note from the CIM server
        /// </summary>
        /// <param name="ID">The unique ID of the note</param>
        /// <param name="CreatedOn">When the note was created or updated</param>
        /// <param name="Author">The author of the note</param>
        /// <param name="Note">The text of the note</param>
        /// <param name="AssociatedElement">The TEID of the note</param>
        public MM_Note(UInt64 ID, DateTime CreatedOn, String Author, String Note, MM_Element AssociatedElement)
        {            
            this.ID = ID;
            this.CreatedOn = CreatedOn;
            this.Author = Author;
            this.Note = Note;
            this.AssociatedElement = AssociatedElement;
        }

        /// <summary>
        /// Create a new note from XML configuration
        /// </summary>
        /// <param name="xBase">The base document</param>
        public MM_Note(XmlElement xBase): base(xBase)
        {            
        }

        /// <summary>
        /// Load a note from the database definition
        /// </summary>
        /// <param name="dRd"></param>
        public MM_Note(DbDataReader dRd)
            : base(dRd)
        { }
        #endregion
    }    
}
